#!/bin/sh

# 获取版本号
config=`sed -n '1p' config/index.ts |awk -F '= ' '{print $2}'`
version=${config:1:4}

path=$(cd `dirname $0`; pwd)
cdnFolder=unimarketing
folder=h5-$cdnFolder

cd .nuxt/dist/client
tar -zcf $path/version/$version.cdn.tar.gz ./*

cd ../../..
tar -zcf $path/version/$version.source.tar.gz .nuxt assets server static package.json tsconfig.json nodemon.json app.html ecosystem.config.js node_modules config nuxt.config.ts

scp ./version/$version.cdn.tar.gz tuijian@qk-nginx-1:/data01/www/protal/h5/$cdnFolder
ssh tuijian@qk-nginx-1 "cd /data01/www/protal/h5/$cdnFolder && sh unzip.sh $version"
echo 'cdn 更新完成'

scp ./version/$version.source.tar.gz tuijian@qk-front-2:/home/tuijian/app/$folder
ssh tuijian@qk-front-2 "cd /home/tuijian/app/$folder && sh update.sh $version"
echo 'qk-front-2 更新完成'

scp ./version/$version.source.tar.gz tuijian@qk-front-3:/home/tuijian/app/$folder
ssh tuijian@qk-front-3 "cd /home/tuijian/app/$folder && sh update.sh $version"
echo 'qk-front-3 更新完成'
